import instance from "./index";
import qs from "qs";
// export function createDepartment(data) {
//   return instance({
//     url: "/dept/create",
//     method: "post",
//     data,
//   });
// }

function buildOptions(data: any, url: string, method?: string) {
  const options: any = {
    method: method || "POST",
    url,
  };
  if (options.method === "GET") {
    options.params = data;
  } else {
    options.data = qs.stringify(data);
  }
  return options;
}

function buildOptions1(data: any, url: string, method?: string) {
  const options: any = {
    method: method || "POST",
    responseType: "blob",
    url,
  };
  if (options.method === "GET") {
    options.params = data;
  } else {
    options.data = qs.stringify(data);
  }
  return options;
}

//编辑简历
export async function save_resumesub(data: any) {
  const options = buildOptions(data, "hr/user/save_resumesub");
  return instance(options);
}

//获取简历
export async function getResume(data: any) {
  //   const options = buildOptions(data, "user/resume?id=" + data, "get");
  const options = buildOptions(data, "hr/user/resume");
  return instance(options);
}

//登记社保
export async function insured_handle(data: any) {
  const options = buildOptions(data, "hr/user/insured_handle");
  return instance(options);
}

//登记公积金
export async function fund_handle(data: any) {
  const options = buildOptions(data, "hr/user/fund_handle");
  return instance(options);
}

//基础信息附件列表(线下)
export async function getFileList(data: any) {
  const options = buildOptions(data, "hr/user/file_list");
  return instance(options);
}

//基础信息附件列表(线上)
export async function getOnlineFileList(data: any) {
  const options = buildOptions(data, "hr/user/file_list_online");
  return instance(options);
}

//基础信息附件列表
export async function deleteFile(data: any) {
  const options = buildOptions(data, "hr/user/file_delete");
  return instance(options);
}

//办理转正
export async function become_handle(data: any) {
  const options = buildOptions(data, "hr/user/become_handle");
  return instance(options);
}

//办理转正
export async function resign_handle(data: any) {
  const options = buildOptions(data, "hr/user/resign_handle");
  return instance(options);
}

//员工启用禁用
export async function set_enable(data: any) {
  const options = buildOptions(data, "hr/user/set_enable");
  return instance(options);
}

//员工管理
export async function getStatistics(data: any) {
  const options = buildOptions(data, "hr/statistics/statistics", "get");
  return instance(options);
}

//员工变动
export async function getChange(data: any) {
  const options = buildOptions(data, "hr/statistics/change");
  return instance(options);
}

//司龄分布
export async function getCompanyAge(data: any) {
  const options = buildOptions(data, "hr/statistics/company_age");
  return instance(options);
}

//员工流失
export async function getLose(data: any) {
  const options = buildOptions(data, "hr/statistics/lose");
  return instance(options);
}

//员工分布
export async function getDistribution(data: any) {
  const options = buildOptions(data, "hr/statistics/distribution");
  return instance(options);
}

//学历分布
export async function getResumeSub(data: any) {
  const options = buildOptions(data, "hr/statistics/resume_sub");
  return instance(options);
}

//年龄分布
export async function getAge(data: any) {
  const options = buildOptions(data, "hr/statistics/age");
  return instance(options);
}

//性别分布
export async function getSex(data: any) {
  const options = buildOptions(data, "hr/statistics/sex");
  return instance(options);
}

//场景列表
export async function getSceneList(data: any) {
  const options = buildOptions(data, "hr/contract/scene_list", "get");
  return instance(options);
}

//分类列表
export async function getCateList(data: any) {
  const options = buildOptions(data, "hr/contract/cate_list?scene_id=" + data, "get");
  return instance(options);
}

//获取员工信息
export async function user_info(data) {
  const options = buildOptions(data, "hr/user/user_info?id=" + data, "GET");
  return instance(options);
}

//合同列表
export async function getContractList(data: any) {
  const options = buildOptions(data, "hr/Contract/index");
  return instance(options);
}

//获取问题
export async function getQuestion(data: any) {
  const options = buildOptions(data, "hr/Contract/get_question");
  return instance(options);
}

//社保导出
export async function insuredExport(data: any) {
  const options = buildOptions1(data, "hr/import/insured_export");
  return instance(options);
}

//公积金导出
export async function fundExport(data: any) {
  const options = buildOptions1(data, "hr/import/fund_export");
  return instance(options);
}

//看板导出
export async function statExport(data: any) {
  const options = buildOptions1(data, "hr/import/export");
  return instance(options);
}

//公积金统计
export async function fundTotal(data: any) {
  const options = buildOptions(data, "hr/statistics/fund", "get");
  return instance(options);
}

//社保统计
export async function insuredTotal(data: any) {
  const options = buildOptions(data, "hr/statistics/insured", "get");
  return instance(options);
}

//公司信息
export async function getCompanyInfo(data: any) {
  const options = buildOptions(data, "hr/backtuning/company_info", "get");
  return instance(options);
}

//背调列表
export async function backtuningList(data: any) {
  const options = buildOptions(data, "hr/backtuning/index");
  return instance(options);
}

//背调取消
export async function cancelBacktuning(data: any) {
  const options = buildOptions(data, "hr/backtuning/cancel_backtuning?id=" + data, "get");
  return instance(options);
}

//背调发起
export async function addBacktuning(data: any) {
  const options = buildOptions(data, "hr/backtuning/add_backtuning");
  return instance(options);
}

//下载合同
export async function downloadContract(data: any) {
  const options = buildOptions(data, "hr/contract/download_contract");
  return instance(options);
}

//检查状态
export async function checkStatus(data: any) {
  const options = buildOptions(data, "hr/backtuning/check_status");
  return instance(options);
}

//下载报告
export async function downloadReport(data: any) {
  const options = buildOptions(data, "hr/backtuning/DownloadReport");
  return instance(options);
}

//购买背调
export async function rechargeBackTuning(data: any) {
  const options = buildOptions(data, "hr/backtuning/recharge");
  return instance(options);
}

//商品信息
export async function getProductList() {
  const options = buildOptions("", "hr/backtuning/product", "get");
  return instance(options);
}

//背调权益
export async function getBdTips() {
  const options = buildOptions("", "hr/backtuning/bd_tips", "get");
  return instance(options);
}

//检查状态
export async function checkOrder(data: any) {
  const options = buildOptions(data, "hr/backtuning/check_order?id=" + data, "get");
  return instance(options);
}

//背调次数记录
export async function getLogList(data: any) {
  const options = buildOptions(data, "hr/backtuning/log_list");
  return instance(options);
}

//合同详情
export async function getContractDetail(data: any) {
  const options = buildOptions("", "hr/manpower/getContractDetail?task_id=" + data + "&isDraft=2", "GET");
  return instance(options);
}

//合同详情-签署
export async function getSignContractDetail(data: any) {
  const options = buildOptions(data, "hr/manpower/sign_contract_detail");
  return instance(options);
}

//发起合同
export async function startContract(data: any) {
  const options = buildOptions(data, "hr/manpower/startContract");
  return instance(options);
}

//签署合同
export async function signContractDraft(data: any) {
  const options = buildOptions(data, "hr/manpower/signContractDraft");
  return instance(options);
}

//签署合同
export async function getCycleUserLog(data: any) {
  const options = buildOptions(data, "hr/user/user_log");
  return instance(options);
}
